# = test.photo.12.rb -  Photo Options Test
# 
# See LICENSE.txt for licensing details.
#
# == Description
#To test and verify : a)  navigate to a photo and b) verify size and details of the photo.
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
require 'watir'
include Watir
require 'test/unit'
require '../watir.config.rb'
require '../resources/functions.rb'

class TC_PhotoOptions_test < Test::Unit::TestCase
    
    def startup
      @@ie = Watir::IE.start($SITE_URL)
    end
    
    def ie
      if defined? @@ie
        @@ie
      else
        startup
      end
    end
    
    def test_01_verifyHomeText
        assert(ie.contains_text(/Community Server/))	
    end
      
    def test_02_verifyLoginLinksExist
      if !(ie.link(:text, 'Sign in').exists?)
        ie.goto($SITE_URL + 'logout.aspx')
        ie.refresh
        ie.goto($SITE_URL)
        ie.refresh
      end
	  end
        
    def test_03_navigateToPhoto
      ie.goto($SITE_URL + 'photos/default.aspx')
      ie.link(:text, 'Sample').click
      assert(ie.link(:url, /picture1.aspx/).exists?)
      ie.link(:url, /picture1.aspx/).click
    end
    
    def test_04_verifyPhotoSizes
      assert(ie.link(:text, 'View Sizes').exists?)
      ie.link(:text, 'View Sizes').click
      
      assert(ie.link(:text, 'Thumbnail').exists?)
      assert(ie.link(:text, 'Small').exists?)
      assert(ie.link(:text, 'Medium').exists?)
      assert(ie.link(:text, 'Large').exists?)
      assert(ie.link(:text, 'Original').exists?)
      
      ie.link(:text, 'View Sizes').click
    end
    
    def test_05_verifyPhotoDetails
      assert(ie.link(:text, 'View Details').exists?)
      ie.link(:text, 'View Details').click
      
      assert(ie.div(:id, 'ViewExif').exists?)
      ie.link(:text, 'View Details').click
    end
    
    def test_99_closeIE
      ie.close
    end
    
end